package com.jnc.plug.mybatis.mp.generator.config;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.jnc.plug.mybatis.mp.generator.custom.CusTypeConvert;

/**
 * @Description
 * @Author fanlei
 * @Version 1.0
 * @Date 2019/9/28
 */
public class CustomDataSourceConfig {
    private AutoGenerator mpg;

    public CustomDataSourceConfig(AutoGenerator mpg) {
        this.mpg = mpg;
    }

    public void invoke() {
        mpg.setDataSource(new DataSourceConfig()
                .setDbType(Context.dbType) // 数据库类型
                .setTypeConvert(new CusTypeConvert())
                .setDriverName(Context.driverName)
                .setUsername(Context.username)
                .setPassword(Context.password)
                .setUrl(Context.url));
    }
}
